#ifndef MESSAGE_CLIENT_CLIENT_H__
#define MESSAGE_CLIENT_CLIENT_H__

#include "client-id.h"
#include "message.h"
#include "fingerprint.h"

namespace messages {

enum {
    HELLO = 64,
    ASK_ABOUT_FILE,
    SEND_AVAILABLE_CHUNKS,
    ASK_FILE_PART,
    SEND_FILE_PART,
};

// trimite un mesaj de autentificare catre un alt
// client. daca autentificarea esueaza conexiunea este
// inchisa, deci nu avem nevoie de NACK
class Hello : public Message {
public:
    Hello();
    Hello(ClientId id);

    virtual ~Hello() {
    }

protected:
    virtual void parse_array(const QByteArray* array, int* position);
    virtual void build_array(QByteArray* array) const;

private:
    ClientId id_;
};

class AskAboutFile : public Message {
public:
    AskAboutFile();
    AskAboutFile(const FingerPrint& finger);

    virtual ~AskAboutFile() {
    }

    const FingerPrint& finger() const {
        return finger_;
    }

protected:
    virtual void parse_array(const QByteArray* array, int* position);
    virtual void build_array(QByteArray* array) const;

private:
    FingerPrint finger_;
};

class SendAvailableChunks : public Message {
public:
    SendAvailableChunks();
    SendAvailableChunks(const QByteArray& bitmap);

    virtual ~SendAvailableChunks() {
    }

    const QByteArray& bitmap() const {
        return bitmap_;
    }

protected:
    virtual void parse_array(const QByteArray* array, int* position);
    virtual void build_array(QByteArray* array) const;

private:
    QByteArray bitmap_;
};

class AskFilePart : public Message {
public:
    AskFilePart();
    AskFilePart(const FingerPrint& finger, quint32 start, quint32 length);

    virtual ~AskFilePart() {
    }

protected:
    virtual void parse_array(const QByteArray* array, int* position);
    virtual void build_array(QByteArray* array) const;

private:
    FingerPrint finger_;
    quint32 start_;
    quint32 length_;
};

class SendFilePart : public Message {
public:
    SendFilePart();
    SendFilePart(const FingerPrint& finger, const QByteArray& data);

    virtual ~SendFilePart() {
    }

protected:
    virtual void parse_array(const QByteArray* array, int* position);
    virtual void build_array(QByteArray* array) const;

private:
    FingerPrint finger_;
	QByteArray data_;
};

};

#endif
